<%@ page contentType="text/html" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<script>
function submitData(){
	if(!loginForm.userName.value){
		alert("请输入用户名");
		loginForm.userName.focus();
		return false;
	}
	if(!loginForm.password.value){
		alert("请输入密码");
		loginForm.password.focus();
		document.getElementById("inputPassword").style.display = "";
		document.getElementById("inputPassword").style.color = "red";
		return false;
	}
	loginForm.submit();
}

function validateUserName(){
	if(!loginForm.userName.value){
		document.getElementById("inputUsername").style.display = "";
		document.getElementById("inputUsername").style.color = "red";
		return false;
	}else{
		document.getElementById("inputUsername").style.display = "none";
	}
}

function validatePassword(){
	if(!loginForm.password.value){
		document.getElementById("inputPassword").style.display = "";
		document.getElementById("inputPassword").style.color = "red";
		return false;
	}else{
		document.getElementById("inputPassword").style.display = "none";
	}
}
</script>

<body bgColor=white>
	<form id="loginForm" action="demo/login.do" method="post">
		<table align="center" border=0 cellSpacing=0 cellPadding=5 width="100%">
			<tr>
				<td align="right" width="300">用户名:</td>
				<td align="left" width="100">
					<input type="text" name="userName" id="userName" onblur="validateUserName()">
				</td>
				<td id="inputUsername" style="display:none">请输入用户名</td>
			</tr>
			<tr>
				<td align="right">密码:</td>
				<td>
					<input type="password" name="password" id="password" onblur="validatePassword()">
				</td>
				<td id="inputPassword" style="display:none">请输入密码</td>
			</tr>
			<tr>
				<td align="right">
					
				</td>
				<td>
					<input type="button" value="登录" onclick="submitData();">
					<input type="reset" value="取消">
				</td>
				<td>
				</td>
			</tr>
		</table>
	</form>

</body>
</html>